<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>阶乘</title>
<script>
  function factorial(n) {
    var result = 1;
    for (n; n > 0; n--) {
      result = result * n;
    }
    return result;
  }
  document.write(factorial(5));
</script>
</head>
<body>
</body>
</html>